﻿using System;

namespace Library.OrmEnterpriseEntity.TableInfo {
	///<summary>
	///</summary>
	public class UnicodeColumn : StringColumn {

		internal static readonly Type UnicodeColumnType = typeof(UnicodeColumn);
		internal class UnicodeColumnMetadata : UnicodeColumn {


			private readonly string _columnName;
			private readonly bool _isKey;
			private readonly bool _forceHasValue;
			private readonly bool _unique;
			private readonly int _len;
			//	private readonly bool _isPassword;
			public UnicodeColumnMetadata(string columnName, bool isKey, bool forceHasValue, bool unique, int len, DbTable table) :
				base(null, table) {
				_columnName = columnName;
				_isKey = isKey;
				_forceHasValue = forceHasValue;
				_unique = unique;
				_len = len;
				//	_isPassword = isPassword;
			}
			public override string ColumnName {
				get { return _columnName; }
			}
			public override bool IsKey {
				get { return _isKey; }
			}
			public override bool Unique {
				get { return _unique; }
			}
			public override bool ForceHasValue {
				get { return _forceHasValue; }
			}
			public override int Len {
				get { return _len; }
			}
			//public override bool IsPassword {
			//  get { return _isPassword; }
			//}




		}
		///<summary>
		///</summary>
		///<param name="metadata"></param>
		///<param name="table"></param>
		public UnicodeColumn(StringColumnView metadata, DbTable table)
			: base(metadata, table) {
		}

		//public override System.Data.DbType DbType {
		//  get { return System.Data.DbType.String; }
		//}
		///<summary>
		///</summary>
		///<param name="value"></param>
		///<returns></returns>
		public static implicit operator UnicodeColumn(string value) {
			if (value == null) value = String.Empty;
			return new UnicodeColumn(UnicodeColumnView.Null, DbTable.Null) { Value = value };
		}
	}
}
